package com.zhangx.study.demo.mysql.run;

import java.util.Random;

public class CreateData {

    static String SQL_PREFIX = "INSERT INTO s2(key1,key2,key3,key_part1,key_part2,key_part3,common_field) VALUES";

    public static String getRandomString(int length){
        String str="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
        Random random = new Random();
        StringBuffer sb=new StringBuffer();
        for(int i=0;i<length;i++){
            int number=random.nextInt(62);
            sb.append(str.charAt(number));
        }
        return sb.toString();
    }
    public static void main(String[] args) {
        StringBuffer sb= new StringBuffer();
        for (int i = 1; i <= 10000 ; i++) {
            int key2 = i;
            Random random = new Random();
            int l1 = random.nextInt(10);
            String key1 = getRandomString(l1);
            int l3 = random.nextInt(10);
            String key3 = getRandomString(l3);
            int lp1 = random.nextInt(10);
            String keyPart1 = getRandomString(lp1);
            int lp2 = random.nextInt(10);
            String keyPart2 = getRandomString(lp2);
            int lp3 = random.nextInt(10);
            String keyPart3 = getRandomString(lp3);
            String commonFiled = getRandomString(random.nextInt(15));
            sb.append("('").append(key1).append("',");
            sb.append(key2).append(",");
            sb.append("'").append(key3).append("',");
            sb.append("'").append(keyPart1).append("',");
            sb.append("'").append(keyPart2).append("',");
            sb.append("'").append(keyPart3).append("',");
            sb.append("'").append(commonFiled).append("'),");
        }
        System.out.println(SQL_PREFIX + sb.toString());
    }
}
